<!--
	时间：2018-07-29
	描述：菜单栏
-->
<script>
	//页面加载函数
	$(function(){
		//获取用户用户名
		HM.ajax("/user?md=currentname","",function(vo){
			//如果有数据
			if(vo.code == 1){
				//获取下用户名
				var nickname = vo.data;
				
				//改变登录按钮处的样式
				var li ="<li>"+nickname+"：欢迎您</li>";
				li+="<li><a href='javascript:;' onclick='logout()'>注销登录</a></li>"
				li+="<li><a href='http://www.xyshopping.com:8848/qianduan/view/cart/list.html'>购物车</a></li>"
				li+="<li><a href='http://www.xyshopping.com:8848/qianduan/view/order/list.html'>我的订单</a></li>"
				
				//覆盖原样式
				$("#login-menu").html(li);
			}else{
				//没登录 什么也不用做
			}
		})
		
		//显示分类信息
		//1.发请求要分类数据
		HM.ajax("/category?md=list","",function(vo){
			//2.接收数据 数组格式 --> 遍历
			var categoryList = vo.data;
			for(c of categoryList){
				//3.拼接a标签 地址链接先不设置
				var li = "<li><a href='http://www.xyshopping.com:8848/qianduan/view/product/list.html?cid="+c.cid+"'>"+c.cname+"</a></li>"
				$("#cate_list").append(li);
			}
		})
		
		
		
		
		
		
		
		
		
		
	})

	
	
	function logout(){
		//啥叫退出？ 请求服务器销毁session
		HM.ajax("/user?md=logout","",function(vo){
			//刷新页面
			location.reload();
		})
	}
</script>
<div class="container-fluid">
	<div class="col-md-4">
		<img src="http://www.xyshopping.com:8848/qianduan/resources/img/logo.png" />
	</div>
	<div class="col-md-5">
		<img src="http://www.xyshopping.com:8848/qianduan/resources/img/header.png" />
	</div>
	<div class="col-md-3" style="padding-top:20px">
		<ol class="list-inline" id="login-menu">
			<li><a href="http://www.xyshopping.com:8848/qianduan/login.html">登录</a></li>
			<li><a href="http://www.xyshopping.com:8848/qianduan/register.html">注册</a></li>
			<li><a href="http://www.xyshopping.com:8848/qianduan/view/cart/list.html">购物车</a></li>
			<li><a href="http://www.xyshopping.com:8848/qianduan/view/order/list.html">我的订单</a></li>
		</ol>
	</div>
</div>
<!--
	时间：2018-07-29
	描述：导航条
-->
<div class="container-fluid">
	<nav class="navbar navbar-inverse">
		<div class="container-fluid">
			<!-- Brand and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="http://www.xyshopping.com:8848/qianduan/index.html">首页</a>
			</div>

			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav" id="cate_list">
					
				</ul>
				<form class="navbar-form navbar-right" role="search">
					<div class="form-group">
						<input type="text" class="form-control" placeholder="Search">
					</div>
					<button type="submit" class="btn btn-default">Submit</button>
				</form>

			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container-fluid -->
	</nav>
</div>